import java.util.ArrayList;
import java.util.List;

/**
 * @author hewei
 * @version 1.0
 * @description: 1023. 驼峰式匹配
 * @date 2022/10/18 19:53
 */

public class CamelMatch {

    public List<Boolean> camelMatch(String[] queries, String pattern) {
        int n = queries.length;
        List<Boolean> ans = new ArrayList<>(n);
        pattern += '~';
        for (String query : queries) {
            int p1 = 0;
            int p2 = 0;
            boolean flag = false;
            while (p1 < query.length() && p2 < pattern.length()) {
                char c1 = query.charAt(p1);
                char c2 = pattern.charAt(p2);
                if (c1 == c2) {
                    ++p2;
                } else if (Character.isUpperCase(c1)) {
                    flag = true;
                    break;
                }
                ++p1;
            }
            if (p2 != pattern.length() - 1 || flag) {
                ans.add(false);
            } else ans.add(true);
        }
        return ans;
    }
}
